package com.ruoyi.web.controller.check;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.check.domain.ECheckListFormSubItem;
import com.ruoyi.check.service.IECheckListFormSubItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检点项Controller
 *
 * @author hugh.sun
 * @date 2023-03-23
 */
@RestController
@RequestMapping("/check/item")
public class ECheckListFormSubItemController extends BaseController
{
    @Autowired
    private IECheckListFormSubItemService eCheckListFormSubItemService;

    /**
     * 查询检点项列表
     */
    @PreAuthorize("@ss.hasPermi('check:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(ECheckListFormSubItem eCheckListFormSubItem)
    {

        startPage();
        List<ECheckListFormSubItem> list = eCheckListFormSubItemService.selectECheckListFormSubItemList(eCheckListFormSubItem);
        return getDataTable(list);
    }

    /**
     * 导出检点项列表
     */
    @PreAuthorize("@ss.hasPermi('check:item:export')")
    @Log(title = "检点项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ECheckListFormSubItem eCheckListFormSubItem)
    {
        List<ECheckListFormSubItem> list = eCheckListFormSubItemService.selectECheckListFormSubItemList(eCheckListFormSubItem);
        ExcelUtil<ECheckListFormSubItem> util = new ExcelUtil<ECheckListFormSubItem>(ECheckListFormSubItem.class);
        util.exportExcel(response, list, "检点项数据");
    }

    /**
     * 获取检点项详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eCheckListFormSubItemService.selectECheckListFormSubItemById(id));
    }

    /**
     * 新增检点项
     */
    @PreAuthorize("@ss.hasPermi('check:item:add')")
    @Log(title = "检点项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ECheckListFormSubItem eCheckListFormSubItem)
    {
        return toAjax(eCheckListFormSubItemService.insertECheckListFormSubItem(eCheckListFormSubItem));
    }

    /**
     * 修改检点项
     */
    @PreAuthorize("@ss.hasPermi('check:item:edit')")
    @Log(title = "检点项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ECheckListFormSubItem eCheckListFormSubItem)
    {

        return toAjax(eCheckListFormSubItemService.updateECheckListFormSubItem(eCheckListFormSubItem));

    }

    /**
     * 删除检点项
     */
    @PreAuthorize("@ss.hasPermi('check:item:remove')")
    @Log(title = "检点项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(eCheckListFormSubItemService.deleteECheckListFormSubItemByIds(ids));

    }
}
